package com.ionehe.group.common.uaa.ex.utils;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Date;

/**
 * Copyright (c) 2020 ionehe.com数美科技有限公司
 * Date: 2020/1/6
 * Time: 19:24
 *
 * @author 2020年 <a href="mailto:zhoulc@supaur.com">秀</a>
 * 【Date类型转时间戳】
 */
public class Date2LongSerializer extends JsonSerializer<Date> {

    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeNumber(date.getTime());
    }
}

